﻿<Page
    x:Name="pageRoot"
    x:Class="Manhua2.Pages.ViewPageNew"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Manhua2.Pages"
    xmlns:converter="using:Manhua2.Converter"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    Tapped="Page_Tapped" DoubleTapped="Page_DoubleTapped">
    
    <Page.Resources>
        <converter:BooleanToVisibilityConverter x:Key="bool2Visibility" />
    </Page.Resources>

    <Grid Style="{StaticResource LayoutRootStyle}">
        <ProgressRing IsActive="{Binding Config.Loading}" Visibility="Visible" Height="50" Width="50" />
        <ScrollViewer x:Name="scrollViewer"
                      HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible"
                      MaxZoomFactor="{Binding Config.MaxScale}" MinZoomFactor="{Binding Config.MinScale}">
            <Image x:Name="image" Stretch="None"
                ImageOpened="Image_ImageOpened"
                ImageFailed="Image_ImageFailed">
            </Image>
        </ScrollViewer>
    </Grid>

    <Page.TopAppBar>
        <AppBar>
            <StackPanel Orientation="Horizontal">
                <Button x:Name="btnGoBack" 
                        Style="{StaticResource BackAppBarButtonStyle}"
                        AutomationProperties.Name="返回"
                        Click="GoBack"/>
                <TextBlock Text="{Binding ComicTitle}" FontSize="32" Margin="10,5,0,0" Style="{StaticResource HeaderTextStyle}"  />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="{Binding ChapterTitle}" />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="当前第" />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="{Binding Page}" />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="页" />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="总共" />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="{Binding TotalPage}" />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="页" />

                <Button x:Name="btnDownload" 
                        Style="{StaticResource DownloadAppBarButtonStyle}"
                        AutomationProperties.Name="下载" Click="btnDownload_Click"
                        Visibility="{Binding Config.IsBtnVisibility}"/>

                <Button x:Name="btnFavorite" Style="{StaticResource FavoriteAppBarButtonStyle}"
                        AutomationProperties.Name="添加收藏" Click="btnFavorite_Click"
                        Visibility="{Binding Config.IsBtnVisibility}"/>
            </StackPanel>
        </AppBar>
    </Page.TopAppBar>
    <Page.BottomAppBar>
        <AppBar>
            <StackPanel Orientation="Vertical">
                <StackPanel Orientation="Horizontal">
                    <Button x:Name="btnHome" Style="{StaticResource HomeAppBarButtonStyle}"
                        AutomationProperties.Name="主页" Click="btnHome_Click" />
                    <Button x:Name="btnDetail" Style="{StaticResource ViewAllAppBarButtonStyle}"
                        AutomationProperties.Name="目录" Click="btnDetail_Click" />

                    <Button x:Name="btnPrevious" Style="{StaticResource SkipBackAppBarButtonStyle}"
                        AutomationProperties.Name="上一章" Click="btnPrevious_Click"
                        Visibility="{Binding Config.IsBtnVisibility}" />
                    <Button x:Name="btnNext" Style="{StaticResource SkipAheadAppBarButtonStyle}"
                        AutomationProperties.Name="下一章" Click="btnNext_Click"
                        Visibility="{Binding Config.IsBtnVisibility}" />
                    <Button x:Name="btnPreviousPage" Style="{StaticResource PreviousAppBarButtonStyle}"
                        AutomationProperties.Name="上一页"
                        Visibility="{Binding Config.IsBtnVisibility}" Click="btnPreviousPage_Click"/>
                    <Button x:Name="btnNextPage" Style="{StaticResource NextAppBarButtonStyle}"
                        AutomationProperties.Name="下一页"
                        Visibility="{Binding Config.IsBtnVisibility}" Click="btnNextPage_Click"/>

                    <TextBox x:Name="txtGoPage" Height="0" Width="0" TextAlignment="Center" Text="1"
                         Visibility="{Binding Config.IsBtnVisibility}" />
                    <TextBlock Text="页" Style="{StaticResource SubheaderTextStyle}" VerticalAlignment="Center" 
                           Height="37" Width="34" Visibility="{Binding Config.IsBtnVisibility}" />
                    <Button x:Name="btnGo" Style="{StaticResource GoAppBarButtonStyle}"
                        AutomationProperties.Name="跳转" Click="btnGo_Click"
                        Visibility="{Binding Config.IsBtnVisibility}"/>
                </StackPanel> 
                <StackPanel Orientation="Horizontal">               
                    <Button x:Name="btnZoomIn" Style="{StaticResource ZoomInAppBarButtonStyle}" 
                            AutomationProperties.Name="放大" Click="btnZoomIn_Click"
                            Visibility="{Binding Config.IsBtnVisibility}" />
                    <Button x:Name="btnZoomOut" Style="{StaticResource ZoomOutAppBarButtonStyle}" 
                            AutomationProperties.Name="缩小" Click="btnZoomOut_Click"
                            Visibility="{Binding Config.IsBtnVisibility}"/>
                    
                    <ToggleSwitch x:Name="direction" OffContent="右方向翻页" OnContent="左方向翻页" 
                                  Visibility="{Binding Config.IsBtnVisibility}" />
                </StackPanel>
            </StackPanel>
        </AppBar>
    </Page.BottomAppBar>
</Page>